<div class="maintop">
    当前位置：系统充值线路管理 > 编辑
    <a href="javascript:;" action="<?=$basepath?>" class="mainFrame button">返回</a>
    <a href="javascript:;" action="<?=$basepath?>_edit?id=<?=$data['id']?>" class="mainFrame button">刷新</a>
</div>
<div style="display:none;" class="hiddencontentdiv"><textarea id="hiddencontent" name="hiddencontent"></textarea></div>
<div id="mainbody">
    <div class="main">
        <form name="add_save" action="<?=$basepath?>_edit_save" method="POST" target="ajax" func="form_submit">
            <input type="hidden" name="id" value="<?=$data['id']?>" />
            <div class="info">
                <div id="infos1">
                    <dl><dt>充值通道</dt><dd><select name="paywayid">
                                <? foreach ($payway as $k=>$v){ ?>
                                    <option value="<?=$v['id']?>" payclass="<?=$v['payclass']?>"><?=$v['title']?>【<?=$v['info']?>】</option>
                                <? } ?>
                            </select></dd><dd><?=$data['payclass']?></dd></dl>
                    <dl><dt>充值赠送</dt><dd><input name="give" type="text" class="mint" value="<?=$data['give']?>" /> %</dd></dl>
                    <!--支付宝-->
                    <dl class="transfer bankids"><dt>开户行</dt><dd><select name="bankid">
                                <?php foreach ($bankslist as $k=>$v){ ?>
                                <label><option value="<?=$v['id']?>"><?=$v['title']?></option>
                                    <?php } ?>
                            </select> </dd></dl>
                    <dl class="transfer"><dt class="username">开户名</dt><dd><input name="username" type="text" class="wtxt" value="<?=$data['username']?>" placeholder="银行的开户姓名" /></dd></dl>
                    <dl><dt class="account">账号</dt><dd><input name="account" type="text" class="wtxt" value="<?=$data['account']?>" placeholder="账号" /></dd></dl>
                    <dl class="transfer"><dt class="openodds">开户地址</dt><dd><input name="openadds" type="text" class="wtxt" value="<?=$data['openadds']?>" placeholder="银行卡的开户行地址" /></dd></dl>
                    <dl class="online"><dt class="memcode">合作者身份ID</dt><dd><input name="memcode" type="text" class="wtxt" value="<?=$data['memcode']?>" placeholder="支付宝合作者身份ID，以2088开头的16位纯数字" /></dd></dl>
                    <dl class="online"><dt>MD5密钥</dt><dd><input name="md5key" type="text" class="wtxt" value="<?=$data['md5key']?>" placeholder="第三方提供或生成的MD5密钥" /></dd></dl>
                    <dl class="online"><dt>RSA密钥</dt><dd><textarea name="rsaprikey" class="wtxt" placeholder="本地生成的RSA密钥" style="width:100%;min-height:60px"><?=$data['rsaprikey']?></textarea></dd></dl>
                    <dl class="online"><dt>RSA公钥</dt><dd><textarea name="pubkey" class="wtxt" placeholder="本地生成，更新到第三方支付的公钥" style="width:100%;min-height:60px"><?=$data['pubkey']?></textarea></dd></dl>
                    <dl class="online"><dt>提交地址</dt><dd><input name="posturl" type="text" class="wtxt" value="<?=$data['posturl']?>" placeholder="本地POST提交地址，需是第三方认可的，APP线路无需填写" /></dd></dl>
                    <dl class="online"><dt>认证域名</dt><dd><input name="creurl" type="text" class="wtxt" value="<?=$data['creurl']?>" placeholder="进入第三方白名单的域名：http://pay.domain.com" /></dd></dl>
                    <dl class="qrcode"><dt>二维码</dt><dd><input name="qrcodeurl" id="qrcodeurl" type="text" class="wtxt" value="<?=$data['posturl']?>" placeholder="上传或选择二维码地址" /></dd><dd><input type="button" name="uploadbutton" id="uploadbutton" value="选择" /></dd></dl>
                    <dl><dt>应用平台</dt><dd><input type="text" name="payfrom" class="int" value="<?=$data['payfrom']?>"></dd><dd class="t">web =&gt; 网页,　app =&gt; APP应用,　mobile =&gt; 移动网页，用“,”分开</dd></dl>
                    <dl><dt>使用状态</dt><dd><select name="state">
                                <option value="0" selected="selected"'>禁用</option>
                                <option value="1">启用</option>
                            </select></dd>
                        <dl><dt>排序</dt><dd><input type="number" name="sort" class="int" value="<?=$data['sort'] ?>" /></dd><dd class="t">按5,4,3,2,1的倒序排序</dd></dl>
                        <dl><dt>&nbsp;</dt>
                            <dd>
                                <input type="submit" value="确认" class="btnbig" />
                                <a href="javascript:;" action="<?=$basepath?>" class="mainFrame btnbig">返回</a>
                            </dd></dl>
                </div>
            </div>

        </form>
    </div>
</div>
<script type="text/javascript">
    $(document).ready(function(){
        function paywaySelect(payclass){
            var memcode_label = '商户编号';
            var memcode_place = '第三方提供的商户唯一编号';
            var account_label = '商户帐号';
            var account_place = '第三方提供的唯一收款帐号';
            switch(payclass)
            {
                case 'weixun':
                case 'weixinh5':
                case 'wxpayapp':
                    memcode_label = "APPID";
                    memcode_place = '微信开放平台审核通过的应用APPID';
                    account_label = '商户号';
                    account_place = '微信支付分配的商户号';
                    $(".transfer").hide();
                    $(".qrcode").hide();
                    $(".online").show();
                    break;
                case 'alipay':
                    memcode_label = "合作者身份ID";
                    memcode_place = '支付宝合作者身份ID，以2088开头的16位纯数字';
                    account_label = '支付宝账号';
                    account_place = '支付宝账号';
                    $(".transfer").hide();
                    $(".qrcode").hide();
                    $(".online").show();
                    break;
                case 'transfer':
                    account_label = '银行卡号';
                    account_place = '银行卡上面的数字';
                    $(".online").hide();
                    $(".qrcode").hide();
                    $(".transfer").show();
                    break;
                case 'qrcodepay':
                    memcode_label = "线路名称";
                    memcode_place = '请填写 - 微信或支付宝';
                    account_label = '收款人姓名';
                    account_place = '二维码收款人的姓名';
                    $(".online").hide();
                    $(".transfer").show();
                    $("select[name=bankid]").parent('dd').parent('.transfer').hide();
                    $("input[name=openadds]").parent("dd").parent(".transfer").hide();
                    $(".username").html(memcode_label);
                    $("input[name=username]").attr('placeholder',memcode_place);
                    $(".qrcode").show();
                    break;
                default:
                    $(".transfer").hide();
                    $(".qrcode").hide();
                    $(".online").show();
                    break;
            }
            $(".memcode").html(memcode_label);
            $(".account").html(account_label);
            $("input[name=memcode]").attr('placeholder',memcode_place);
            $("input[name=account]").attr('placeholder',account_place);
        }
        <?php
        if(!empty($data['paywayid'])){
            echo '$("select[name=\'paywayid\'] option[value=\''.$data['paywayid'].'\']").attr("selected", "selected");';
            echo 'paywaySelect("'.$data['payclass'].'");';
        }
        if(!empty($data['bankid'])){
            echo '$("select[name=\'bankid\'] option[value=\''.$data['bankid'].'\']").attr("selected", "selected");';
        }
        if(!empty($data['state'])){
            echo '$("select[name=\'state\'] option[value=\''.$data['state'].'\']").attr("selected", "selected");';
        }

        ?>
        $("input[name=bankslist]").on("click",function (e) {
            var _selectId = "";
            var arrChk=$("input[name=bankslist]:checked");
            $(arrChk).each(function(){
                _selectId += ',' + this.value;
            });
            _selectId = _selectId.substr(1,_selectId.length-1);
            $("input[name=banks]").val(_selectId);
        });
        $("select[name=paywayid]").on("change",function (e) {
            var payclass = $(this).find("option:selected").attr("payclass");
            paywaySelect(payclass);
        });

    });
</script>
<? $this->display('editor',array('textareaid'=>'hiddencontent','uploadbutton'=>'uploadbutton','inputid'=>'qrcodeurl')); ?>
